<template>
  <div class="user-list-container">
    <div v-if="users.length === 0" class="empty-state">
      <div class="empty-icon">👥</div>
      <p class="empty-text">暂无用户数据</p>
    </div>
    
    <div v-else class="users-grid">
      <div 
        v-for="user in users" 
        :key="user.id" 
        class="user-card"
      >
        <div class="user-avatar">
          {{ user.username.charAt(0).toUpperCase() }}
        </div>
        <div class="user-details">
          <h3 class="username">{{ user.username }}</h3>
          <p class="user-id">ID: {{ user.id }}</p>
        </div>
        <button class="more-btn" @click="$emit('edit-user', user)">
          <span class="more-dots">•••</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'UserList',
  props: {
    users: {
      type: Array,
      default: () => []
    }
  },
  emits: ['edit-user', 'refresh']
}
</script>

<style scoped>
.user-list-container {
  margin-top: 8px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #a8a8c5;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-text {
  font-size: 16px;
  margin: 0;
}

.users-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(123, 104, 238, 0.08);
  border: 1px solid rgba(123, 104, 238, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.user-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, #7b68ee 0%, #9370db 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(123, 104, 238, 0.15);
}

.user-card:hover::before {
  opacity: 1;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b68ee 0%, #9370db 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 18px;
  margin-right: 16px;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
}

.username {
  color: #4a4a6a;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.user-id {
  color: #8a8aa3;
  font-size: 12px;
  margin: 0;
}

.more-btn {
  background: rgba(123, 104, 238, 0.1);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.more-btn:hover {
  background: rgba(123, 104, 238, 0.2);
  transform: scale(1.1);
}

.more-dots {
  color: #7b68ee;
  font-size: 16px;
  font-weight: 600;
}

@media (max-width: 480px) {
  .user-card {
    padding: 14px;
    border-radius: 14px;
  }
  
  .user-avatar {
    width: 44px;
    height: 44px;
    font-size: 16px;
    margin-right: 14px;
  }
  
  .username {
    font-size: 15px;
  }
  
  .more-btn {
    width: 36px;
    height: 36px;
  }
}
</style>
